<?php
include "p_usuario/valida_credenciais.php";
$valCr = new valida_credenciais();
//$nivel define o array de acessos, ou seja, os grupos que podem acessar essa pagina
$nivel = array(1,2,3);
if(!($valCr->validar($nivel))){
	header('Location: index.php?p=denied');
}

?>

<script language="javascript" type="text/javascript" src="p_igreja/valida_form.js"></script>
<div class="form bg-warning">
	<div class="row">
		<div class="col-md-12">
			<div class="page-header">
				<h2>Adicionar Igreja/Congregação</h2>
			</div>
		</div>
	</div>
	<div class="row">
	<div class="col-md-3">
			<div class="actions">
				<div class="panel panel-default">
					<div class="panel-heading"><h5>Opções</h5></div>
						<div class="panel-body">
							<ul class="nav nav-pills nav-stacked">
								<li><a href="index.php?p=igrejas">Listar Igrejas</a></li>
								
							</ul>
						</div>
					</div>
				</div>			
		</div><!-- end col md 3 -->
		<div class="col-md-9">
		<!-- HEAD DE FORMULÃ�RIO -->
		<div class="panel panel-default">
			<div class="panel-heading"><h5>Formulário de Cadastro de nova Igreja ou Congregação</h5></div>
			<div class="panel-body">
			<!-- FORMULÃ�RIO -->
			<form  method="post" name="form1" action="p_igreja/salvar.php" enctype="multipart/form-data">
				<div class="row">
					<div class="col-md-12 form-group"><h6>(<span class="text-danger">*</span>) Campos de preenchimento obrigatório.</h6></div>
				</div>
				<div class="row">
					<div class="form-group col-md-9">
						<label for="nome">Igreja ou Congregação (<span class="text-danger">*</span>)</label>
    					<input type="text" class="form-control" name="igreja" id="igreja" placeholder="igreja..">
                                        </div>
                                        <div class="form-group col-md-3">
						<label for="tipo_igr">Tipo de Igreja (<span class="text-danger">*</span>)</label>
    					<select name="tipo-igreja" id="tipoigreja" class="form-control">
		          			<option value='selecione'>Selecione...</option>
		          			<?php
						        $query = mysql_query("SELECT id, tipo_igr FROM tipo_igrejas");
						        while($lista = mysql_fetch_array($query)) { ?> 
							        <option value="<?php echo $lista['id']; ?>"><?php echo $lista['tipo_igr']; ?></option>
						<?php }?>		
			 		</select>
		        		</div>
				</div>
				<div class="row">	
					<div class="form-group col-md-6">
					    <label for="descricao" title="Descricao da Igreja">Descrição</label>
    					    <input type="text" class="form-control" id="descricao" name="descricao" placeholder="descricao.." maxlength="11">
					</div>	
					<div class="form-group col-md-6">
			    			<label for="membro_id">Pastor Responsável</label>
	    					<select name="membro_id" id="membro_id" class="form-control">
			          			<option value='selecione'>Selecione...</option>
			          			<?php
						    	$query = mysql_query("SELECT id, membro, tipo_membro_id FROM membros WHERE membros.tipo_membro_id = 1");
							while($lista = mysql_fetch_array($query)) { ?> 
				        			<option value="<?php echo $lista['id']; ?>"><?php echo $lista['membro']; ?></option>
		        				<?php }?>
			          		</select>
					</div>
				</div>
				<div class="row">
					<div class="form-group col-md-6">
						<label for="dep">Departamento</label>
    					<select name="dep" id="dep" class="form-control">
		          			<option value='Selecione'>Selecione...</option>
		          			<?php
						        $query = mysql_query("SELECT id, departamento FROM departamentos");
						        while($lista = mysql_fetch_array($query)) { ?> 
							        <option value="<?php echo $lista['id']; ?>"><?php echo $lista['departamento']; ?></option>
						<?php }?>		
			 		</select>
		        		</div>

				</div>
	
				<h5 class="page-header">Contato</h5>
				<div class="row">
					<div class="form-group col-md-4">
						<label for="tel-fixo">Telefone Fixo (<span class="text-danger">*</span>)</label>
    					<input type="text" class="form-control" id="telfixo" name="tel-fixo" placeholder="(67) 3232-5511"  onkeypress="MascaraTelefone(form1.telfixo);" maxlength="14" onBlur="ValidaTelefone(form1.telfixo);">
					</div>
					<div class="form-group col-md-4">
						<label for="tel-cel">Telefone Celular (<span class="text-danger">*</span>)</label>
    					<input type="text" class="form-control" id="telcel" name="tel-cel" placeholder="(67) 9944-5511" maxlength="14" onkeypress="MascaraTelefone(form1.telcel);" onBlur="ValidaTelefone(form1.telcel);">
					</div>
					<div class="form-group col-md-4">
						<label for="tel-aux">Telefone Auxiliar</label>
    					<input type="text" class="form-control" id="telaux" name="tel-aux" placeholder="(67) 0000-0000" maxlength="14" onkeypress="MascaraTelefone(form1.telaux);" >
					</div>
				</div>
				<div class="row">
					<div class="form-group col-md-6">
						<label for="email">Email (<span class="text-danger">*</span>)</label>
    					<input type="text" class="form-control" id="email" name="email" placeholder="email@email.com">
					</div>
					<div class="form-group col-md-6">
						<label for="email-aux">Email Auxiliar</label>
    					<input type="text" class="form-control" id="emailaux" name="email-aux" placeholder="email@email.com">
					</div>
				</div>
				<h5 class="page-header">Endereço</h5>
				<div class="row">
					<div class="form-group col-md-8">
						<label for="rua">Rua (<span class="text-danger">*</span>)</label>
    					<input type="text" class="form-control" id="rua" name="rua">
					</div>
					<div class="form-group col-md-4">
						<label for="rua">Número (<span class="text-danger">*</span>)</label>
    					<input type="text" class="form-control" id="numero" name="numero" maxlength="5">
					</div>
				</div>
				<div class="row">
					<div class="form-group col-md-6">
						<label for="ref">Referência</label>
    					<input type="text" class="form-control" id="ref" name="ref">
					</div>
					<div class="form-group col-md-6">
						<label for="compl">Complemento</label>
    					<input type="text" class="form-control" id="compl" name="compl">
					</div>
				</div>
				<div class="row">
					<div class="form-group col-md-6">
						<label for="bairro">Bairro (<span class="text-danger">*</span>)</label>
    					<input type="text" class="form-control" id="bairro" name="bairro">
					</div>
					<div class="form-group col-md-2">
						<label for="cep">CEP (<span class="text-danger">*</span>)</label>
    					<input type="text" class="form-control" id="cep" name="cep" maxlength="10" onkeypress="MascaraCep(form1.cep);" onBlur="ValidaCep(form1.cep)">
					</div>
					
				</div>
				<div class="row">
					<div class="form-group col-md-6">
						<label for="cidade">Cidade (<span class="text-danger">*</span>)</label>
    					<input type="text" class="form-control" id="cidade" name="cidade">
					</div>
					<div class="form-group col-md-6">
						<label for="estado">Estado (<span class="text-danger">*</span>)</label>
    					<select name="estado" id="estado" class="form-control">
		          			<option value='selecione'>Selecione...</option>
		          			<?php
							$query = mysql_query("SELECT id, estados.estado FROM estados");
							while($lista = mysql_fetch_array($query)) { ?> 
						    	<option value="<?php echo $lista['id']; ?>"><?php echo $lista['estado']; ?></option>
						<?php } mysql_close();?>
		          		</select>
					</div>
				</div>
				
				<br>
				<div class="row">
					<div class="form-group col-md-2">
						<input type="submit" value="Salvar" class="btn btn-default" name="enviar" onclick="return valida()" >
					</div>
				</div>
			</form>
			</div>
		</div>

		</div><!-- end col md 12 -->
	</div><!-- end row -->
</div>
			
